package pkg

import (
	"chat/config"
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

type TextBaiduResp struct {
	ConclusionType uint64 `json:"conclusionType"`
}

func TextCensor(message string) bool {
	baidu := config.AppConf.Baidu
	client := censor.NewClient(baidu.Ak, baidu.Sk)

	res := client.TextCensor(message)
	var resp TextBaiduResp
	_ = json.Unmarshal([]byte(res), &resp)
	if resp.ConclusionType == 1 {
		return true
	}
	return false
}
